package com.cdream.basic.classiccase.miaosha.service.impl;

import cn.hutool.core.util.IdUtil;
import com.cdream.basic.classiccase.miaosha.entity.StockLog;
import com.cdream.basic.classiccase.miaosha.mapper.StockLogMapper;
import com.cdream.basic.classiccase.miaosha.service.StockLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zs
 * @since 2021-07-17
 */
@Service
public class StockLogServiceImpl extends ServiceImpl<StockLogMapper, StockLog> implements StockLogService {
    @Override
    @Transactional
    public StockLog initStockLog(Integer itemId, Integer amount){
        StockLog stockLog = StockLog.builder().itemId(itemId).amount(amount).stockLogId(IdUtil.simpleUUID()).status(1).build();
        this.save(stockLog);
        return stockLog;
    }
}
